<%= form_for(@route) do |f| %>
  <% if @route.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@route.errors.count, "error") %> prohibited this route from being saved:</h2>

      <ul>
      <% @route.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :name %><br />
    <%# f.text_field :name, :value => generate_route_name %>
    <%= f.text_field :name %>
  </div>
  <div class="field">
    <%= f.label "Farbe" %><br />
    <%= f.select :color_id, @colors.collect{|x| [x.name, x.id]}, :prompt => "Farbe auswählen" %>
  </div>
  <div class="field">
    <%= f.label "Geschraubt am:" %><br />
    <%= f.date_select :build %>
  </div>
  <div class="field">
    <%= f.label "Schwierigkeit" %><br />
    <%= f.select :grade_id, @grades.collect{|x| [x.grade, x.id]}, :prompt => "Grad auswählen" %>
  </div>
 <div class="field">
    <%= f.label "Umlenker" %><br />
    <%= f.select :chain_id, @chains.collect{|x| [x.number.to_s + " " + x.wall.name, x.id]}, :prompt => "Umlenker auswählen" %>
  </div>
  <% if @user.is_schorsch? %>
  <div class="field">
    <%= f.label "Rausschrauben" %><br />
    <%= f.check_box :rework %>
  </div>
  <% end %>
  <% if @user.is_schorsch? %>
  <div class="field">
    <%= f.label "Eingebort" %><br />
    <%= check_box_tag("route[existent]", "1", (@new ? true : false) ) %>
  </div>
  <% end %>


  <div class="field">
    <%= f.label "Bauarbeiter" %><br />
   <% @workers.each do |worker| %>
			<%= check_box_tag(
                            "route[workers_list][#{worker.id}]", 
                            "1", 
                            @route.workers.detect{|d| d == worker} || (@new && (worker == @user)) ) %>
			<%= "#{worker.name}"%><br />
		<% end %>
 </div>
  <div class="actions">
    <%= f.submit "Neue Route anlegen" %>
  </div>
<% end %>
